package com.fingard.dsp.bank.reqrespobj.deposit;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.dsp.bank.reqrespobj.deposit.detail.RetAts7507Detail;
import com.fingard.xml.XmlTextWriter;

/**
 * Created by F on 2018/10/9.
 */
public class RetAts7507DepQry extends RetAtsBase {

    //private boolean isLastSetRespInfo = false;
    private int writeRdCount = 0;

    public RetAts7507DepQry(ReqRespHeader p_header) {
        retHeader = p_header;
        retXmlWriter = new XmlTextWriter();
    }

    public int getWrittenRdCount() {
        return  writeRdCount;
    }

    private void writeInsert(String insert) throws Exception {
        //查存单
        retXmlWriter.writeElementString("Insert", insert);
    }

    public void writeRetDetail(RetAts7507Detail p_retDetail) throws Exception {
        writeRdCount++;
        if (writeRdCount == 1) {
            if (!hasWrittenRespCode) {
                writeRespCode("0");
            }
            if (!hasWrittenRespInfo) {
                writeRespInfo("");
            }
            writeInsert("1");
        }
        retXmlWriter.writeStartElement("DetailRecord");
        retXmlWriter.writeElementString("ActNum", p_retDetail.actNum);
        retXmlWriter.writeElementString("ActArea", p_retDetail.actArea);
        retXmlWriter.writeElementString("DepositCode", p_retDetail.depositCode);
        retXmlWriter.writeElementString("StartDate", p_retDetail.startDate);
        retXmlWriter.writeElementString("EndDate", p_retDetail.endDate);
        retXmlWriter.writeElementString("ValueDate", p_retDetail.valueDate);
        retXmlWriter.writeElementString("Terms", p_retDetail.terms);
        retXmlWriter.writeElementString("CurrencyID", p_retDetail.currencyID);
        retXmlWriter.writeElementString("OriPrincipal", p_retDetail.oriPrincipal);
        retXmlWriter.writeElementString("NoteMoney", p_retDetail.noteMoney);
        retXmlWriter.writeElementString("Rate", p_retDetail.rate);
        retXmlWriter.writeElementString("InterestMoney", p_retDetail.interestMoney);
        retXmlWriter.writeElementString("DepositStates", p_retDetail.depositStates);
        retXmlWriter.writeElementString("DumpFlag", p_retDetail.dumpFlag);
        retXmlWriter.writeElementString("DrawDate", p_retDetail.drawDate);
        retXmlWriter.writeEndElement();
    }
}
